#include<iostream>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<map>
#include<set>
#include<bits/stdc++.h>
#include<unordered_set>
#define fi first
#define se second
#define SIZE(x) ((int)x.size())
#define out(x) cerr<<#x<<" = "<<(x)<<endl;
#define MP(a,b) make_pair(a,b)
using namespace std;
typedef long long ll;
#define VI vector<int>
#define VVI vector< vector<int> >
#define VD vector<double>
#define VVD vector<VD >
#define VC vector<char>
#define PI pair<int,int>
#define PL pair<ll,ll>
#define EPS 0.0000001


inline int lson(int x){return x<<1;}
inline int rson(int x){return (x<<1)|1;}

inline int read()
{
        int x=0,f=1;char ch=getchar();
        while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
        while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
        return x*f;
}

template<typename T>
inline void read(T &x){
        x=0;T f=1;char ch;
        do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
        do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

struct no{
  ll flg,y,a,b;
  bool operator<(const no&x)const{
    if(y!=x.y)return y<x.y;
    return flg<x.flg;
  }
};


no ev[200005];
ll su=0;

ll arr[200005];
ll xn=0;
//为什么是8倍呢，因为四倍线段树。而且pushup里面对于叶子节点又访问了叶子节点。所以一共是8倍。
ll len[8*200005];
ll cnt[8*200005];

void pushup(ll a,ll b,ll x){
  if(cnt[x])len[x]=arr[b+1]-arr[a];
  else len[x]=len[lson(x)]+len[rson(x)];
}

void upd(ll l,ll r,ll a,ll b,ll x,ll c){
  if(a>=l&&b<=r){
    cnt[x]+=c;
    pushup(a,b,x);
    return;
  }
  ll mid=(a+b)/2;
  if(l<=mid)upd(l,r,a,mid,lson(x),c);
  if(r>mid)upd(l,r,mid+1,b,rson(x),c);
  pushup(a,b,x);
}

int main(){
    #ifdef BUG
    freopen("a.in","r",stdin);
    #endif
    ll n=read();
    ll a,b,c,d;
    for(ll i=0;i<n;i++){
      a=read();b=read();c=read();d=read();
	  if(a==c||b==d)continue;
      ev[su++]={1,b,a,c};
      ev[su++]={0,d,a,c};
      arr[++xn]=a;
      arr[++xn]=c;
    }
    sort(ev,ev+su);
    sort(arr+1,arr+xn+1);
    xn=unique(arr+1,arr+xn+1)-arr-1;
    memset(len,0,sizeof len);
    memset(cnt,0,sizeof cnt);
    ll lasty=0;
    ll res=0;
    for(ll i=0;i<su;i++){
      if(ev[i].y!=lasty){
        //cout<<len[1]<<endl;
        res+=(ev[i].y-lasty)*len[1];
        lasty=ev[i].y;
      }
      ll t1=lower_bound(arr+1,arr+xn+1,ev[i].a)-arr,
        t2=lower_bound(arr+1,arr+xn+1,ev[i].b)-arr-1;
      //cout<<arr[t1]<<' '<<arr[t2+1]<<endl;
      upd(t1,t2,1,xn-1,1,ev[i].flg?1:-1);
    }
    cout<<res<<endl;
}